<!DOCTYPE html>
<html lang="zh-cn">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>Typecho下使用多说显示UA信息 - Feng&#39;s Blog - 大灰鼠的博客</title>
  <meta name="renderer" content="webkit" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>

<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<meta name="theme-color" content="#f8f5ec" />
<meta name="msapplication-navbutton-color" content="#f8f5ec">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="#f8f5ec">


<meta name="author" content="Feng" /><meta name="description" content="记得在使用Wordpress时，给评论加过UA（访问者信息，如系统、浏览器等），比较简单只需要使用相应的插件即可，随着自己的博客改用Type" /><meta name="keywords" content="feng, 折腾人生, 电脑维修, 手机玩转, 技术心得, 拆机, 网站建设, 快乐悠悠, uu, 悠悠, 博客" />






<meta name="generator" content="Hugo 0.76.5 with theme even" />


<link rel="canonical" href="https://uu126.gitee.io/2016/333.html" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/manifest.json">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">



<link href="/sass/main.min.c7bc1becf36bcf6a9ebd25d2947e43a2eb745ddb0c9a32b43126fd7fa460c351.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.css" integrity="sha256-7TyXnr2YU040zfSP+rEcz29ggW4j56/ujTPwjMzyqFY=" crossorigin="anonymous">


<meta property="og:title" content="Typecho下使用多说显示UA信息" />
<meta property="og:description" content="记得在使用Wordpress时，给评论加过UA（访问者信息，如系统、浏览器等），比较简单只需要使用相应的插件即可，随着自己的博客改用Type" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://uu126.gitee.io/2016/333.html" />
<meta property="article:published_time" content="2016-11-27T20:21:00+00:00" />
<meta property="article:modified_time" content="2016-11-27T20:21:00+00:00" />
<meta itemprop="name" content="Typecho下使用多说显示UA信息">
<meta itemprop="description" content="记得在使用Wordpress时，给评论加过UA（访问者信息，如系统、浏览器等），比较简单只需要使用相应的插件即可，随着自己的博客改用Type">
<meta itemprop="datePublished" content="2016-11-27T20:21:00+00:00" />
<meta itemprop="dateModified" content="2016-11-27T20:21:00+00:00" />
<meta itemprop="wordCount" content="1445">



<meta itemprop="keywords" content="typecho,网站," />
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Typecho下使用多说显示UA信息"/>
<meta name="twitter:description" content="记得在使用Wordpress时，给评论加过UA（访问者信息，如系统、浏览器等），比较简单只需要使用相应的插件即可，随着自己的博客改用Type"/>

<!--[if lte IE 9]>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/classlist/1.1.20170427/classList.min.js"></script>
<![endif]-->

<!--[if lt IE 9]>
  <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
<![endif]-->

</head>
<body>
  <div id="mobile-navbar" class="mobile-navbar">
  <div class="mobile-header-logo">
    <a href="/" class="logo">Feng&#39;s Blog</a>
  </div>
  <div class="mobile-navbar-icon">
    <span></span>
    <span></span>
    <span></span>
  </div>
</div>
<nav id="mobile-menu" class="mobile-menu slideout-menu">
  <ul class="mobile-menu-list">
    <a href="/">
        <li class="mobile-menu-item">Home</li>
      </a><a href="/post/">
        <li class="mobile-menu-item">Archives</li>
      </a><a href="/tags/">
        <li class="mobile-menu-item">Tags</li>
      </a><a href="/links/">
        <li class="mobile-menu-item">Links</li>
      </a><a href="/ly/">
        <li class="mobile-menu-item">Ly</li>
      </a><a href="/about/">
        <li class="mobile-menu-item">About</li>
      </a>
  </ul>
</nav>
  <div class="container" id="mobile-panel">
    <header id="header" class="header">
        <div class="logo-wrapper">
  <a href="/" class="logo">Feng&#39;s Blog</a>
</div>

<nav class="site-navbar">
  <ul id="menu" class="menu">
    <li class="menu-item">
        <a class="menu-item-link" href="/">Home</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/post/">Archives</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/tags/">Tags</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/links/">Links</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/ly/">Ly</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/about/">About</a>
      </li>
  </ul>
</nav>
    </header>

    <main id="main" class="main">
      <div class="content-wrapper">
        <div id="content" class="content">
          <article class="post">
    
    <header class="post-header">
      <h1 class="post-title">Typecho下使用多说显示UA信息</h1>

      <div class="post-meta">
        <span class="post-time"> 2016-11-27 </span>
        <div class="post-category">
            <a href="/categories/%E7%BD%91%E7%AB%99%E5%BB%BA%E8%AE%BE/"> 网站建设 </a>
            </div>
          <span class="more-meta"> 约 1445 字 </span>
          <span class="more-meta"> 预计阅读 3 分钟 </span>
        
      </div>
    </header>

    <div class="post-toc" id="post-toc">
  <h2 class="post-toc-title">文章目录</h2>
  <div class="post-toc-content always-active">
    <nav id="TableOfContents"></nav>
  </div>
</div>
    <div class="post-content">
      <p>记得在使用Wordpress时，给评论加过UA（访问者信息，如系统、浏览器等），比较简单只需要使用相应的插件即可，随着自己的博客改用Typecho后，原来的这些插件也就用不了，但也不能阻挡我那股折腾的心呀，现在博客使用的是多说的评论系统，网上看了一下教程还是蛮多的，但大部分是针对Wordpress的，虽然都是PHP架构的，还是要亲身体验过才知道好不好用。试了很多位博主的办法都不行（可能是俺功力还不够吧），不过也还是让俺给找到了，并且测试过好用，目前本站已经用上了，需要看效果的可以自己评论一下就可是看到了，好了，开始分享工作：</p>
<p>1、先下载多说的embed.js文件，多说现在对Https的支持已经有所改观了，可以下载：<a href="https://static.duoshuo.com/embed.js" target="_blank"  rel="nofollow" ><a href="https://static.duoshuo.com/embed.js">https://static.duoshuo.com/embed.js</a></a></p>
<p>2、下载好后，打开编辑（本人不建议使用记事本，可以使用Notepad等软件，也方便），在最前面加入以下代码：</p>
<pre><code class="lang-java">//移动客户端判断开始，作用：在移动客户端显示不同样式
function sskcheckMobile(){
    var isiPad = navigator.userAgent.match(/iPad/i) != null;
    if(isiPad){
        return false;
    }
    var isMobile=navigator.userAgent.match(/iphone|android|phone|mobile|wap|netfront|x11|java|opera mobi|opera mini|ucweb|windows ce|symbian|symbianos|series|webos|sony|blackberry|dopod|nokia|samsung|palmsource|xda|pieplus|meizu|midp|cldc|motorola|foma|docomo|up.browser|up.link|blazer|helio|hosin|huawei|novarra|coolpad|webos|techfaith|palmsource|alcatel|amoi|ktouch|nexian|ericsson|philips|sagem|wellcom|bunjalloo|maui|smartphone|iemobile|spice|bird|zte-|longcos|pantech|gionee|portalmmm|jig browser|hiptop|benq|haier|^lct|320x320|240x320|176x220/i)!= null;
    if(isMobile){
        return true;
    }
    return false;
}
//移动客户端判断结束
//显UA开始
function sskua(e) {
 var r = new Array;
 var outputer = '';
 if (r = e.match(/FireFox\/([^\s]+)/ig)) {
 var r1 = r[0].split("/");
 outputer = ' Mozilla FireFox' + '|' + r1[1]
 } else if (r = e.match(/Maxthon([\d]*)\/([^\s]+)/ig)) {
 var r1 = r[0].split("/");
 outputer = ' Maxthon'
 } else if (r = e.match(/BIDUBrowser([\d]*)\/([^\s]+)/ig)) {
 var r1 = r[0].split("/");
 outputer = ' 百度浏览器' + '|' + r1[1]
 } else if (r = e.match(/UBrowser([\d]*)\/([^\s]+)/ig)) {
 var r1 = r[0].split("/");
 outputer = ' UCBrowser' + '|' + r1[1]
 } else if (r = e.match(/UCBrowser([\d]*)\/([^\s]+)/ig)) {
 var r1 = r[0].split("/");
 outputer = ' UCBrowser' + '|' + r1[1]
 } else if (r = e.match(/MetaSr/ig)) {
 outputer = ' 搜狗浏览器'
 } else if (r = e.match(/2345Explorer/ig)) {
 outputer = ' 2345王牌浏览器'
 } else if (r = e.match(/2345chrome/ig)) {
 outputer = ' 2345加速浏览器'
 } else if (r = e.match(/LBBROWSER/ig)) {
 outputer = ' 猎豹安全浏览器'
 } else if (r = e.match(/MicroMessenger\/([^\s]+)/ig)) {
 var r1 = r[0].split("/");
 outputer = ' 微信' + '|' + r1[1]/*.split('/')[0]*/
 } else if (r = e.match(/QQBrowser\/([^\s]+)/ig)) {
 var r1 = r[0].split("/");
 outputer = ' QQ浏览器' + '|' + r1[1]/*.split('/')[0]*/
 } else if (r = e.match(/QQ\/([^\s]+)/ig)) {
 var r1 = r[0].split("/");
 outputer = ' QQ浏览器' + '|' + r1[1]/*.split('/')[0]*/
 } else if (r = e.match(/MiuiBrowser\/([^\s]+)/ig)) {
 var r1 = r[0].split("/");
 outputer = ' Miui浏览器' + '|' + r1[1]/*.split('/')[0]*/
 } else if (r = e.match(/Chrome([\d]*)\/([^\s]+)/ig)) {
 var r1 = r[0].split("/");
 outputer = ' Chrome' + '|' + r1[1]/*.split('.')[0]*/
 } else if (r = e.match(/safari\/([^\s]+)/ig)) {
 var r1 = r[0].split("/");
 outputer = ' Apple Safari' + '|' + r1[1]
 } else if (r = e.match(/Opera[\s|\/]([^\s]+)/ig)) {
 var r1 = r[0].split("/");
 outputer = ' Opera' + '|' + r[1]
 } else if (r = e.match(/Trident\/7.0/gi)) {
 outputer = ' Internet Explorer 11'
 } else if (r = e.match(/MSIE\s([^\s|;]+)/gi)) {
 outputer = ' Internet Explorer' + '|' + r[0]/*.replace('MSIE', '').split('.')[0]*/
 } else {
 outputer = ' 其它浏览器'
 }
 if(sskcheckMobile()){
 Mobile='';
 }else{
 Mobile='';
 }
 return outputer+""+Mobile ;
 }
 function sskos(e) {
 var os = '';
 if (e.match(/win/ig)) {
 if (e.match(/nt 5.1/ig)) {
 os = ' Windows XP'
 } else if (e.match(/nt 6.1/ig)) {
 os = ' Windows 7'
 } else if (e.match(/nt 6.2/ig)) {
 os = ' Windows 8'
 } else if (e.match(/nt 6.3/ig)) {
 os = ' Windows 8.1'
 } else if (e.match(/nt 10.0/ig)) {
 os = ' Windows 10'
 } else if (e.match(/nt 6.0/ig)) {
 os = ' Windows Vista'
 } else if (e.match(/nt 5/ig)) {
 os = ' Windows 2000'
 } else {
 os = ' Windows'
 }
 } else if (e.match(/android/ig)) {
 os = ' Android'
 } else if (e.match(/ubuntu/ig)) {
 os = ' Ubuntu'
 } else if (e.match(/linux/ig)) {
 os = ' Linux'
 } else if (e.match(/mac/ig)) {
 os = ' Mac OS X'
 } else if (e.match(/unix/ig)) {
 os = ' Unix'
 } else if (e.match(/symbian/ig)) {
 os = ' Nokia SymbianOS'
 } else {
 os = ' 其它操作系统'
 }
 return os+"" ;
 }
//显UA结束</code></pre>
<p>3、接着搜索</p>
<pre><code class="lang-java">data-qqt-account="' + (r.qqt_account || "") + '"&gt;' + u(r.name) + ""),</code></pre>
<p>如果查不到，可以尝试缩短关键词查询，在后面增加：</p>
<pre><code class="lang-java">t += "" + sskua(s.agent) + "" + sskos(s.agent) + "",</code></pre>
<p>注意是增加，不是覆盖哦。</p>
<p>4、增加美观度，可以在主题的style.css或多说设置中的自定义css（本人用的是后者，为什么？换主题不影响呀），代码如下：</p>
<pre><code class="lang-css">    /*多说UA开始*/
span.ua{
 margin: 0 1px!important;
 color:#FFFFFF!important;
 /*text-transform: Capitalize!important;
 float: right!important;
 line-height: 18px!important;*/
}
.ua_other.os_other{
 background-color: #ccc!important;
 color: #fff;
 border: 1px solid #BBB!important;
 border-radius: 4px;
}
.ua_ie{
 background-color: #428bca!important;
 border-color: #357ebd!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.ua_firefox{
 background-color: #f0ad4e!important;
 border-color: #eea236!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.ua_maxthon{
 background-color: #7373B9!important;
 border-color: #7373B9!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.ua_ucweb{
 background-color: #FF740F!important;
 border-color: #d43f3a!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.ua_sogou{
 background-color: #78ACE9!important;
 border-color: #4cae4c!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.ua_2345explorer{
 background-color: #2478B8!important;
 border-color: #4cae4c!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.ua_2345chrome{
 background-color: #F9D024!important;
 border-color: #4cae4c!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.ua_mi{
 background-color: #FF4A00!important;
 border-color: #4cae4c!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.ua_lbbrowser{
 background-color: #FC9D2E!important;
 border-color: #4cae4c!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.ua_chrome{
 background-color: #EE6252!important;
 border-color: #4cae4c!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.ua_qq{
 background-color: #3D88A8!important;
 border-color: #4cae4c!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.ua_apple{
 background-color: #E95620!important;
 border-color: #4cae4c!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.ua_opera{
 background-color: #d9534f!important;
 border-color: #d43f3a!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.os_vista,.os_2000,.os_windows,.os_xp,.os_7,.os_8,.os_8_1 {
 background-color: #39b3d7!important;
 border-color: #46b8da!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.os_android {
 background-color: #98C13D!important;
 border-color: #01B171!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.os_ubuntu{
 background-color: #DD4814!important;
 border-color: #01B171!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.os_linux {
 background-color: #3A3A3A!important;
 border-color: #1F1F1F!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.os_mac{
 background-color: #666666!important;
 border-color: #1F1F1F!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.os_unix{
 background-color: #006600!important;
 border-color: #1F1F1F!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
.os_nokia{
 background-color: #014485!important;
 border-color: #1F1F1F!important;
 border-radius: 4px;
 padding: 0 5px!important;
}
/*多说UA结束*/</code></pre>
<p>最后，上一个本站的效果图，大伙品尝一下：<br>
<img   class="lazyload" data-src="https://cdn.uu126.cn/usr/uploads/2016/11/3041626217.png" src="https://cdn.jsdelivr.net/gh/moezx/cdn@3.0.2/img/svg/loader/trans.ajax-spinner-preloader.svg" onerror="imgError(this)"  alt="20161127202015.png" title="20161127202015.png" /></p>
<noscript>
  <img src="https://cdn.uu126.cn/usr/uploads/2016/11/3041626217.png" alt="20161127202015.png" title="20161127202015.png" /></p>
</noscript>
<p>　</p>

    </div>

    <div class="post-copyright">
  <p class="copyright-item">
    <span class="item-title">文章作者</span>
    <span class="item-content">Feng</span>
  </p>
  <p class="copyright-item">
    <span class="item-title">上次更新</span>
    <span class="item-content">
        2016-11-27
        
    </span>
  </p>
  
  
</div>
<div class="post-reward">
  <input type="checkbox" name="reward" id="reward" hidden />
  <label class="reward-button" for="reward">赞赏支持</label>
  <div class="qr-code">
    
    <label class="qr-code-image" for="reward">
        <img class="image" src="https://cdn.uu126.cn/hugo/wechat.png">
        <span>微信打赏</span>
      </label>
    <label class="qr-code-image" for="reward">
        <img class="image" src="https://cdn.uu126.cn/hugo/alipay.png">
        <span>支付宝打赏</span>
      </label>
  </div>
</div><footer class="post-footer">
      <div class="post-tags">
          <a href="/tags/typecho/">typecho</a>
          <a href="/tags/%E7%BD%91%E7%AB%99/">网站</a>
          </div>
      <nav class="post-nav">
        <a class="prev" href="/2016/334.html">
            <i class="iconfont icon-left"></i>
            <span class="prev-text nav-default">多了一个COM口引起的问题</span>
            <span class="prev-text nav-mobile">上一篇</span>
          </a>
        <a class="next" href="/2016/332.html">
            <span class="next-text nav-default">给Typecho后台添加图片验证</span>
            <span class="next-text nav-mobile">下一篇</span>
            <i class="iconfont icon-right"></i>
          </a>
      </nav>
    </footer>
  </article>
        </div>
        

  
  <div id="vcomments"></div>
  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src='//unpkg.com/valine/dist/Valine.min.js'></script>
  <script type="text/javascript">
    new Valine({
        el: '#vcomments' ,
        appId: '5sMkTX4FLjetFnfbOhaDTCDJ-9Nh9j0Va',
        appKey: '25KXCqIqAN142RQn4fBrsI87',
        notify:  false ,
        verify:  false ,
        avatar:'mm',
        placeholder: '说点什么吧...',
        visitor:  false 
    });
  </script>

  

      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="social-links">
  <a href="https://uu126.gitee.io/index.xml" type="application/rss+xml" class="iconfont icon-rss" title="rss"></a>
</div>

<div class="copyright">
  <span class="copyright-year">  
  Hosted by <a href="https://pages.coding.me" style="font-weight: bold">Coding Pages</a> + <a href="https://cloud.tencent.com/redirect.php?redirect=1005&cps_key=4e78216aea817227ff0c96d93a00fd4b" target="_blank" rel="nofollow">腾讯云 + </a><a href="https://console.upyun.com/register/?invite=S1JeTquHL" target="_blank" rel="nofollow"><span class="with-love"><img src="https://cdn.lancn.cn/images/upyun.png" style="width:45px;vertical-align:middle;" alt="又拍云存储"></span></a>
   </span> 
  <div class="busuanzi-footer">
    <a target="_blank"  href="http://www.beian.miit.gov.cn">浙ICP备11026647号-3</a><span class="post-meta-divider"> | </span><a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=33088102001325"><span class="with-love"><img src="https://cdn.uu126.cn/icon-police.png" style="width:14px;"></span> 浙公网安备33088102001325号</a>
  </div>
  <span class="power-by">
    由 <a class="hexo-link" href="https://gohugo.io">Hugo</a> 强力驱动
  </span>
  <span class="division">|</span>
  <span class="theme-info">
    主题 - 
    <a class="theme-link" href="https://github.com/olOwOlo/hugo-theme-even">Even</a>
  </span>
   

  

  <span class="copyright-year">
    &copy; 
    2012 - 
    2020<span class="heart"><i class="iconfont icon-heart"></i></span><span>Feng</span>
  </span>
</div>

    </footer>

    <div class="back-to-top" id="back-to-top">
      <i class="iconfont icon-up"></i>
    </div>
  </div>
  <script src="/lib/highlight/highlight.pack.js?v=20171001"></script>
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/slideout@1.0.1/dist/slideout.min.js" integrity="sha256-t+zJ/g8/KXIJMjSVQdnibt4dlaDxc9zXr/9oNPeWqdg=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.js" integrity="sha256-XVLffZaxoWfGUEbdzuLi7pwaUJv1cecsQJQqGLe7axY=" crossorigin="anonymous"></script>



<script type="text/javascript" src="/js/main.min.c12618f9a600c40bd024996677e951e64d3487006775aeb22e200c990006c5c7.js"></script>








</body>
</html>
